<?

include_once("sofiles.php");
include_once("sostreams.php");
include_once("sostring.php");

$folder = $argv[1];
if ($folder == "") $folder = ".";

$dir = new soDir($folder, "", "n");
$icount = $dir->count();
if ($icount == 0) die("No files found in '$folder'.\n");

for ($i = 0; $i < $icount; $i++) {
    $name = $dir->getValue($i);

    $file = soFileToString($folder."/".$name);
    $parsed = "<?".soParseVal($file, "<?", "?>", 1)."?>\n";

    if (($name != "cleanphp.php") && ($file != $parsed)) {
        $os = new soOutputStream("file://$folder/$name", $parsed);
        echo "Fixed: '$name'.\n";
    };
    
}; // for $i

echo "Done.";

?>
